package com.xingceng.stock.controller;


import com.xiceng.stock.entity.StockBlockRtInfo;
import com.xiceng.stock.entity.StockBusiness;
import com.xiceng.stock.vo.*;
import com.xingceng.stock.api.StockControllerAPI;
import com.xingceng.stock.response.PageResult;
import com.xingceng.stock.response.ResponseResult;
import com.xingceng.stock.service.StockBlockRtInfoService;
import com.xingceng.stock.service.StockBusinessService;
import com.xingceng.stock.service.StockMarketIndexInfoService;
import com.xingceng.stock.service.StockRtInfoService;
import jakarta.servlet.http.HttpServletResponse;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

/**
 * @author zby
 * @created 2024-06-23 16:33
 * @description 股票接口实现
 */
@RestController
@RequiredArgsConstructor
public class StockController implements StockControllerAPI {

    private final StockBusinessService stockBusinessService;

    private final StockBlockRtInfoService stockBlockRtInfoService;

    private final StockRtInfoService stockRtInfoService;

    private final StockMarketIndexInfoService stockMarketIndexInfoService;


    @Override
    public ResponseResult<List<StockBusiness>> getStockBusiness() {
        List<StockBusiness> stockBusiness = stockBusinessService.list();
        return ResponseResult.ok(stockBusiness);
    }

    @Override
    public ResponseResult<List<InnerMarketVO>> innerIndexAll() {
        return ResponseResult.ok(stockBusinessService.innerIndexAll());
    }

    @Override
    public ResponseResult<List<StockBlockRtInfoVO>> sectorAll() {
        return ResponseResult.ok(stockBlockRtInfoService.sectorAllLimit());
    }

    @Override
    public ResponseResult<List<StockUpdownVO>> stockIncreaseLimit() {
        return ResponseResult.ok(stockRtInfoService.stockIncreaseLimit());
    }

    @Override
    public ResponseResult<PageResult<StockUpdownVO>> stockPage(@RequestParam(name = "page",defaultValue = "1") Integer page
            ,@RequestParam(name = "pageSize",defaultValue = "10") Integer pageSize) {
        return ResponseResult.ok(stockRtInfoService.stockPage(page, pageSize));
    }

    @Override
    public ResponseResult<Map> upDownCount() {
        return ResponseResult.ok(stockRtInfoService.upDownCount()) ;
    }

    @Override
    public ResponseResult stockExport(HttpServletResponse response,@RequestParam(name = "page",defaultValue = "1") Integer page
            ,@RequestParam(name = "pageSize",defaultValue = "10") Integer pageSize) {
        stockRtInfoService.stockExport(response,page,pageSize);
        return ResponseResult.ok() ;
    }

    @Override
    public ResponseResult<Map> stockTradeVol4InnerMarket() {
        return stockMarketIndexInfoService.stockTradeVol4InnerMarket();
    }

    @Override
    public ResponseResult<Map> getStockUpDown() {
        return ResponseResult.ok(stockRtInfoService.stockUpDownScopeCount());
    }

    @Override
    public ResponseResult<List<Stock4MinuteVO>> stockScreenTimeSharing(@RequestParam (name = "code",required = false) String code) {
        return ResponseResult.ok(stockRtInfoService.stockScreenTimeSharing(code));
    }

    @Override
    public ResponseResult<List<Stock4EvrDayVO>> getDayKLinData(@RequestParam("code") String stockCode) {
        return ResponseResult.ok(stockRtInfoService.stockCreenDkLine(stockCode));
    }
}